<% content_for :toolbar do %>
  <%= render "alchemy/admin/pages/toolbar" %>
<% end %>

<%= content_tag :div,
  id: "archive_all",
  class: [@view == "list" && "resources-table-wrapper with_tag_filter"] do %>
  <% if @view == "list" %>
    <%= render "alchemy/admin/resources/table_header", resources_instance_variable: @pages %>
    <% if @pages.any? %>
      <%= render "table" %>
    <% elsif search_filter_params.present? %>
      <%= render_message do %>
        <%= Alchemy.t("No pages found") %>
      <% end %>
    <% elsif can?(:create, Alchemy::Page) %>
      <%= render partial: "create_language_form" %>
    <% end %>

    <%= render "alchemy/admin/resources/pagination", resources: @pages %>

    <div id="library_sidebar">
      <%= render "filter_bar" if resource_has_filters %>
      <%= render "tag_list" if resource_has_tags %>
    </div>
  <% else %>
    <% if @page_root %>
      <h2 id="page_filter_result"></h2>
      <%= render "sitemap", page_partial: "page" %>
    <% elsif can?(:create, Alchemy::Page) %>
      <%= render partial: "create_language_form" %>
    <% else %>
      <%= render_message :warn do %>
        <h2>No language root page found.</h2>
        <p>Please ask the admin to create one.</p>
      <% end %>
    <% end %>
  <% end %>
<% end %>
